﻿using Autodesk.AutoCAD.Runtime;
using McHighwayHollowPierUi.Model;
using System;

namespace McHighwayHollowPierUi
{
    public class McHighwayHollowPierUi : McHighwayHollowPierCli.IMcHighwayHollowPierUi
    {
        public override void showHighwayHollowPierForm(string data, IntPtr owner)
        {
            var viewModel = new HighwayHollowPierViewModel
            {
                Data = Newtonsoft.Json.JsonConvert.DeserializeObject<McHighwayHollowPierData>(data)
            };

            HighwayHollowPierForm form = new HighwayHollowPierForm(viewModel);
            form.Show(System.Windows.Forms.NativeWindow.FromHandle(owner));
        }
    }

    // This class is instantiated by AutoCAD once and kept alive for the 
    // duration of the session. If you don't do any one time initialization 
    // then you should remove this class.
    public class McHighwayHollowPierPlugin : IExtensionApplication
    {
        void IExtensionApplication.Initialize()
        {
            //注入ui接口实现
            McHighwayHollowPierCli.IMcHighwayHollowPierUi.setInstance(new McHighwayHollowPierUi());
        }

        void IExtensionApplication.Terminate()
        {
        }
    }
}
